import my.MyBeanDefinitionRegistryPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import spring.demo.listener.CustomEventPublisher;
import spring.demo.listener.MyEnvent;
import spring.demo.listener.MyListener;

import java.util.Arrays;

class App {
    public static void main(String[] args) {
//        ApplicationContext context1 = new ClassPathXmlApplicationContext("application.xml");
//        FirstService firstService = context1.getBean("firstService", FirstService.class);
//        System.out.println(firstService.getInfo());
//
//        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyListener.class);
//
//        System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"+Arrays.asList(context.getBeanDefinitionNames()));
//        context.scan("spring.demo.listener");
//        System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"+Arrays.asList(context.getBeanDefinitionNames()));
//
//
//        CustomEventPublisher publisher = context.getBean(CustomEventPublisher.class);
//        publisher.doSomethingAndPublishAnEvent("自定义发送消息```");

        ApplicationContext context =  new ClassPathXmlApplicationContext("application.xml");
        FirstService firstService = context.getBean("firstService", FirstService.class);
        String info = firstService.getInfo();
        System.out.println(info);

//        ApplicationContext context = new AnnotationConfigApplicationContext(MyBeanDefinitionRegistryPostProcessor.class);
//        MyBeanDefinitionRegistryPostProcessor post = context.getBean("myBeanDefinitionRegistryPostProcessor", MyBeanDefinitionRegistryPostProcessor.class);

    }
}